package com.qst.action.exam;

import com.qst.BaseServlet;
import com.qst.Constant;
import com.qst.WebUtil;
import com.qst.entity.Schedule;
import com.qst.entity.TestPersonnel;
import com.qst.service.AssessmentService;
import com.qst.service.ExamService;
import com.qst.service.ScheduleService;
import com.qst.service.impl.ServiceFactory;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

//@WebServlet("/exam/list.action")
public class ListServlet extends BaseServlet {
    private AssessmentService assessmentService = ServiceFactory.getService(AssessmentService.class);
    private ExamService examService = ServiceFactory.getService(ExamService.class);
    private ScheduleService scheduleService = ServiceFactory.getService(ScheduleService.class);

    @Override
    protected void doAction(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        TestPersonnel stu = (TestPersonnel) req.getSession().getAttribute(Constant.CURRENT_TESTPERSONNEL);
        List<Schedule> scheduleList = examService.findScheduleByTestPersonnel(stu);
        req.setAttribute("scheduleList", scheduleList);
        WebUtil.forward(req, resp, "/exam/list.jsp");
    }
}
